/***** PROJECTED METHOD CODE *****/
/*****  Alexandre GAILLARD   *****/
/*   This version :: June 2017   */
/*********************************/


// AT THIS STAGE:: WE DON'T USE THE VALUE OF WW, Un, Ui, by assumption, FracskillE = 1.0 //

/********************************************/
/** CONSUMPTION EQUIVALENT VARIATION (CEV) **/
/********************************************/


/** ALONG THE TRANSITIONAL DYNAICS (EV) AND STEADY-STATE (EV_SS) **/
/** save the CEV along the transition, and at the steady_state **/
// WORKER //
// transition
double temp_EVWWE, temp_EVWWNE;
double temp_CONSEVWWE, temp_CONSEVWWNE;
double *EVWWE_T, *EVWWNE_T;
// SS
double temp_EVWWE_SS, temp_EVWWNE_SS;
double temp_CONSEVWWE_SS, temp_CONSEVWWNE_SS;
double *EVWWE_SS, *EVWWNE_SS;

// UNEMPLOYED //
// transition
double temp_EVUiE, temp_EVUnE, temp_EVUiNE, temp_EVUnNE;
double temp_CONSEVUiE, temp_CONSEVUnE, temp_CONSEVUiNE, temp_CONSEVUnNE;
double *EVUiE_T, *EVUnE_T, *EVUiNE_T, *EVUnNE_T; // transition
// SS
double temp_EVUiE_SS, temp_EVUnE_SS, temp_EVUiNE_SS, temp_EVUnNE_SS;
double temp_CONSEVUiE_SS, temp_CONSEVUnE_SS, temp_CONSEVUiNE_SS, temp_CONSEVUnNE_SS;
double *EVUiE_SS, *EVUnE_SS, *EVUiNE_SS, *EVUnNE_SS;

// ENTREPRENEUR //
// transition
double temp_EVJE, temp_EVJNE;
double temp_CONSEVJE, temp_CONSEVJNE;
double *EVJE_T, *EVJEi_T, *EVJNE_T, *EVJNEi_T; // transition
// SS
double temp_EVJE_SS, temp_EVJNE_SS;
double temp_CONSEVJE_SS, temp_CONSEVJNE_SS;
double *EVJE_SS, *EVJEi_SS, *EVJNE_SS, *EVJNEi_SS;


// ALLOCATE THE POINTERS //
// ENTREPRENEUR //
EVJE_T = (double *) calloc((ifulldimE), sizeof(double));
EVJEi_T = (double *) calloc((ifulldimE), sizeof(double));
EVJNE_T = (double *) calloc((ifulldimE), sizeof(double));
EVJNEi_T = (double *) calloc((ifulldimE), sizeof(double));
EVJE_SS = (double *) calloc((ifulldimE), sizeof(double));
EVJEi_SS = (double *) calloc((ifulldimE), sizeof(double));
EVJNE_SS = (double *) calloc((ifulldimE), sizeof(double));
EVJNEi_SS = (double *) calloc((ifulldimE), sizeof(double));

// WORKER //
EVWWE_T = (double *) calloc((ifulldimW), sizeof(double));
EVWWNE_T = (double *) calloc((ifulldimW), sizeof(double));
EVWWE_SS = (double *) calloc((ifulldimW), sizeof(double));
EVWWNE_SS = (double *) calloc((ifulldimW), sizeof(double));

// UNEMPLOYED //
EVUiE_T = (double *) calloc((ifulldim), sizeof(double));
EVUnE_T = (double *) calloc((ifulldim), sizeof(double));
EVUiNE_T = (double *) calloc((ifulldim), sizeof(double));
EVUnNE_T = (double *) calloc((ifulldim), sizeof(double));
EVUiE_SS = (double *) calloc((ifulldim), sizeof(double));
EVUnE_SS = (double *) calloc((ifulldim), sizeof(double));
EVUiNE_SS = (double *) calloc((ifulldim), sizeof(double));
EVUnNE_SS = (double *) calloc((ifulldim), sizeof(double));


/** IMPORT VALUE AT THE END AND AT THE BEGINNING **/
/** need the end and first value functions **/
// FIRST PERIOD VFI (FOR CEV)
double *valueWWNE0, *valueWWE0, *valueUiNE0, *valueUnNE0, *valueUiE0, *valueUnE0;
double *valueJE0,  *valueJNE0;

valueJE0    = (double *) calloc((ifulldimE), sizeof(double));
valueJNE0   = (double *) calloc((ifulldimE), sizeof(double));
valueWWNE0  = (double *) calloc((ifulldimW), sizeof(double));
valueWWE0   = (double *) calloc((ifulldimW), sizeof(double));
valueUnNE0  = (double *) calloc((ifulldim), sizeof(double));
valueUnE0   = (double *) calloc((ifulldim), sizeof(double));
valueUiNE0  = (double *) calloc((ifulldim), sizeof(double));
valueUiE0   = (double *) calloc((ifulldim), sizeof(double));

readinput(valueJE0, ifulldimE, "OUTPUT/project_method/valueJE_0.out");
readinput(valueJNE0, ifulldimE, "OUTPUT/project_method/valueJNE_0.out");
readinput(valueWWNE0, ifulldimW, "OUTPUT/project_method/valueWWNE_0.out");
readinput(valueWWE0, ifulldimW, "OUTPUT/project_method/valueWWE_0.out");
readinput(valueUnNE0, ifulldim, "OUTPUT/project_method/valueUnNE_0.out");
readinput(valueUnE0, ifulldim, "OUTPUT/project_method/valueUnE_0.out");
readinput(valueUiNE0, ifulldim, "OUTPUT/project_method/valueUiNE_0.out");
readinput(valueUiE0, ifulldim, "OUTPUT/project_method/valueUiE_0.out");

// FIRST PERIOD Consumption flow (FOR CEV)
double *C_WWNE0, *C_WWE0, *C_UiNE0, *C_UnNE0, *C_UiE0, *C_UnE0;
double *C_JE0, *C_JNE0;

C_JE0    = (double *) calloc((ifulldimE), sizeof(double));
C_JNE0   = (double *) calloc((ifulldimE), sizeof(double));
C_WWNE0  = (double *) calloc((ifulldimW), sizeof(double));
C_WWE0   = (double *) calloc((ifulldimW), sizeof(double));
C_UnNE0  = (double *) calloc((ifulldim), sizeof(double));
C_UnE0   = (double *) calloc((ifulldim), sizeof(double));
C_UiNE0  = (double *) calloc((ifulldim), sizeof(double));
C_UiE0   = (double *) calloc((ifulldim), sizeof(double));

readinput(C_JE0, ifulldimE, "OUTPUT/project_method/C_JE_0.out");
readinput(C_JNE0, ifulldimE, "OUTPUT/project_method/C_JNE_0.out");
readinput(C_WWNE0, ifulldimW, "OUTPUT/project_method/C_WWNE_0.out");
readinput(C_WWE0, ifulldimW, "OUTPUT/project_method/C_WWE_0.out");
readinput(C_UnNE0, ifulldim, "OUTPUT/project_method/C_UnNE_0.out");
readinput(C_UnE0, ifulldim, "OUTPUT/project_method/C_UnE_0.out");
readinput(C_UiNE0, ifulldim, "OUTPUT/project_method/C_UiNE_0.out");
readinput(C_UiE0, ifulldim, "OUTPUT/project_method/C_UiE_0.out");



